import request from '@/utils/request'

const api = {
  pluginPage: '/system/app/control/page',
  pluginList: '/system/app/control/list',
  start: '/system/app/control/start',
  stop: '/system/app/control/stop',
  onlineInstall: '/system/app/control/onlineInstall',
  onlineUpdate: '/system/app/control/onlineUpdate',
  uninstall: '/system/app/control/uninstall',
  appPage: '/system/app/market/page',
}

export default api

// 获得应用市场分页
export function getAppPage(query) {
  return request({
    url: api.appPage,
    method: 'get',
    params: query
  })
}

export function getPluginPage () {
  return request({
    url: api.pluginPage,
    method: 'get'
  })
}

export function start (id) {
  return request({
    url: api.start + '/' + id,
    method: 'post'
  })
}

export function stop (id) {
  return request({
    url: api.stop + '/' + id,
    method: 'post'
  })
}

export function onlineInstall (data) {
  return request({
    url: api.onlineInstall,
    method: 'post',
    params: data
  })
}
export function onlineUpdate (data) {
  return request({
    url: api.onlineUpdate,
    method: 'post',
    params: data
  })
}

export function uninstall (id) {
  return request({
    url: api.uninstall + '/' + id,
    method: 'post'
  })
}

export function getPluginList () {
  return request({
    url: api.pluginList,
    method: 'get'
  })
}
